#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi

#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > dpt_h2s.info <<%EOF%
   dpt_h2s
   -------
   Molecule:       H2S in C2v
   Wave Function:  CCS, CCSD / cc-pVDZ
   Test Purpose:   First-order relativistic corrections
%EOF%

#######################################################################
#  INTEGRAL INPUT
#######################################################################
cat > dpt_h2s.mol <<%EOF%
BASIS
cc-pVDZ          
First-order relativistic corrections

    2    2  X  Y      1.00D-15
       16.0   1
S       0.00000000000000    0.00000000000000    0.00000000000000       *
        1.0   1
H       1.82237883747756    0.00000000000000    1.75080674629681       *
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > dpt_h2s.dal <<%EOF%
**DALTON INPUT
.RUN WAVE FUNCTIONS
**INTEGRAL
.DIPLEN
.THETA
.EFGCAR
.SECMOM
.DARWIN
.MASSVELO
.DPTPOT
.KINENER
**WAVE FUNCTION
.CC
*SCF INP
.THRESH
 1.0D-10
*CC INP
.CCS
.CCSD
.PRINT
 4
.THRENR
1.0D-10
.THRLEQ
1.0D-07
*CCFOP
.ALLONE
.DPTECO
.2ELDAR
**END OF DALTON INPUT
%EOF%
#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >dpt_h2s.check
cat >>dpt_h2s.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

#        DPTONE:     -2.098783775
#        DPTREO:      0.621248675
#        DPTTWO:      0.367967785
#        Total first-order DPT correction:     -1.109567315
#        1-elec. Darwin term:      3.473561489
#        Mass-Velocity term:      -4.548992379
#        Mass-Velocity + 1-elec. Darwin terms:      -1.075430890
#        2-elec. Darwin term:      -0.034116691
#        Total relativistic correction:      -1.109547582
#        DPTONE:     -2.098702008
#        DPTREO:      0.621290959
#        DPTTWO:      0.367893453
#        Total first-order DPT correction:     -1.109517596
#        1-elec. Darwin term:      3.473603460
#        Mass-Velocity term:      -4.549007622
#        Mass-Velocity + 1-elec. Darwin terms:      -1.075404162
#        2-elec. Darwin term:      -0.034102620
#        Total relativistic correction:      -1.109506782

CRIT1=`$GREP "Total first-order DPT correction:     \-1\.1095673" $log | wc -l`
TEST[1]=`expr   $CRIT1`
CTRL[1]=1
ERROR[1]="CCS first-order DPT correction not correct"

CRIT2=`$GREP "Total first-order DPT correction:     \-1\.1095175" $log | wc -l`
TEST[2]=`expr   $CRIT2`
CTRL[2]=1
ERROR[2]="CCSD first-order DPT correction not correct"

CRIT3=`$GREP "Total relativistic correction:      \-1\.1095475" $log | wc -l`
TEST[3]=`expr   $CRIT3`
CTRL[3]=1
ERROR[3]="CCS first-order Pauli correction not correct"

CRIT4=`$GREP "Total relativistic correction:      \-1\.1095067" $log | wc -l`
TEST[4]=`expr   $CRIT4`
CTRL[4]=1
ERROR[4]="CCSD first-order Pauli correction not correct"

PASSED=1
for i in 1 2 3 4
do
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM
  exit 1
fi                
%EOF%

chmod +x dpt_h2s.check
#######################################################################
